****Preparing the manifesto codings for the analysis****

cd "/Users/christinazuber/Dropbox/collab-projects/Habsburg/Publications/HMD Research Note/Data and analysis/1 data preparation" 

import excel using "Ger_FinalCoding_Variables_recoded.xlsx", sheet("German-alliancesrecoded") firstrow clear
rename Clericalspoliticalcatholicism Clericalspos
rename GT Clericalsneg
gen manifesto_set = "ger"
save "manifestos-ger.dta", replace

import excel using "Cz_FinalCoding_Variables.xlsx", sheet("Czech-alliancesrecoded") firstrow clear 
rename Clericalspoliticalcatholicism Clericalspos
rename GR Clericalsneg
gen manifesto_set = "cze"
save "manifestos-cze.dta", replace

*Combine party manifesto data 
append using "manifestos-ger.dta"
rename militaryserviceconscriptionpo militaryservicepos
rename militaryserviceconscriptionne militaryserviceneg

**Set missings to zero for category not coded for Czech parties (otherwissen summing across missings leads to zero)
replace GreaterGermanypos = 0 if GreaterGermanypos== .
replace GreaterGermanyneg = 0 if GreaterGermanyneg== .
save "manifestos", replace

*drop double coded socdem programme (coded twice in German and in Czech projects. Text was identical. Dropping the Czech version: 
drop if doc_title == "1901 Socdem Programme"

*generate a variable that counds the total number of segments in each document to work with salience scores later on. According to our coding logic, the total number of segments is given by the sum of all issue codings plus the "junk" codings (applied to segments not containing any substantive issue claims). 

gen totalseg = GreaterGermanypos + GreaterGermanyneg + warmilitarismpos+ warmilitarismneg+ militaryservicepos + militaryserviceneg+/*
*/citizenarmypos + citizenarmyneg + democracypos + democracyneg + electoralinclusionpos + electoralinclusionneg +parliamentaryautonomypos + parliamentaryautonomyneg + civillibertiespos + civillibertiesneg + ruleoflawpos + ruleoflawneg +/*
*/specialstatusHungarypos+ specialstatusHungaryneg+ federalismdecentralizationpos+ federalismdecentralizationneg+ secessionpos+ secessionneg+/*
*/capitalismpos+ capitalismneg+ freetradepos+ freetradeneg+ exploitationpos+ exploitationneg+ growthindustrialisationpos +growthindustrialisationneg+ unemploymentpos+ /*
*/unemploymentneg+ inflationpos + inflationneg + publicdebtpos+ publicdebtneg+ lowerinterestratespos+ lowerinterestratesneg+ taxespos+ /*
*/taxesneg+ corporatismpos + corporatismneg + cooperativespos+cooperativesneg+ tradeunionspos+ tradeunionsneg+ publicinfrastructurepos+ publicinfrastructureneg+ publicsubsidiespos + publicsubsidiesneg + agriculturepos + agricultureneg +/*
*/socialequalitypos+ socialequalityneg+ socialsecuritypos+ socialsecurityneg+ publichealthpos+ publichealthneg+ publiceducationpos+ /*
*/publiceducationneg+ classconflictpos+ classconflictneg+ /*
*/traditionalreligvaluespos+ traditionalreligvaluesneg+ separationchurchstatepos+ separationchurchstateneg+/*
*/nationalismpos+ nationalismneg+ speciallanguagerightspos +speciallanguagerightsneg+grouprepresentationpos+ grouprepresentationneg+ immigrationpos+ immigrationneg+/*
*/Otherissue + JUNK

***Calculate the total number of substantive policy issue codings (excluding junk and including otherissue)
gen totalpol = GreaterGermanypos + GreaterGermanyneg + warmilitarismpos+ warmilitarismneg+ militaryservicepos + militaryserviceneg+/*
*/citizenarmypos + citizenarmyneg + democracypos + democracyneg + electoralinclusionpos + electoralinclusionneg +parliamentaryautonomypos + parliamentaryautonomyneg + civillibertiespos + civillibertiesneg + ruleoflawpos + ruleoflawneg +/*
*/specialstatusHungarypos+ specialstatusHungaryneg+ federalismdecentralizationpos+ federalismdecentralizationneg+ secessionpos+ secessionneg+/*
*/capitalismpos+ capitalismneg+ freetradepos+ freetradeneg+ exploitationpos+ exploitationneg+ growthindustrialisationpos +growthindustrialisationneg+ unemploymentpos+ /*
*/unemploymentneg+ inflationpos + inflationneg + publicdebtpos+ publicdebtneg+ lowerinterestratespos+ lowerinterestratesneg+ taxespos+ /*
*/taxesneg+ corporatismpos + corporatismneg + cooperativespos+cooperativesneg+ tradeunionspos+ tradeunionsneg+ publicinfrastructurepos+ publicinfrastructureneg+ publicsubsidiespos + publicsubsidiesneg + agriculturepos + agricultureneg +/*
*/socialequalitypos+ socialequalityneg+ socialsecuritypos+ socialsecurityneg+ publichealthpos+ publichealthneg+ publiceducationpos+ /*
*/publiceducationneg+ classconflictpos+ classconflictneg+ /*
*/traditionalreligvaluespos+ traditionalreligvaluesneg+ separationchurchstatepos+ separationchurchstateneg+/*
*/nationalismpos+ nationalismneg+ speciallanguagerightspos +speciallanguagerightsneg+grouprepresentationpos+ grouprepresentationneg+ immigrationpos+ immigrationneg+/*
*/Otherissue


***Calculate the total number of group appeal codings (including other group, excluding no group )
gen totalgr = civicidentitypos+ civicidentityneg+ /*
*/upperclasspos+ upperclassneg+ middleclasspos+ middleclassneg+ lowerclasspos+ lowerclassneg+ capitalistspos+ capitalistsneg+ workerspos+ workersneg+ aristocratspos+  /*
*/aristocratsneg+ farmerspos+ farmersneg+ merchantspos+ merchantsneg+ craftspeoplepos+ craftspeopleneg+ civilservantsneg+ civilservantspos+ soldierspos+ soldiersneg+  /*
*/intellectualspos+ intellectualsneg+ producerspos+ producersneg+ consumerspos+ consumersneg+ /*
*/croatsneg+ croatspos+ czechspos+ czechsneg+ germanspos+ germansneg+ hungarianspos+ hungariansneg+ italianspos+ italiansneg+ bosniakspos + bosniaksneg + nomadicpeoplepos + nomadicpeopleneg + /*
*/jewspos+ jewsneg+ polespos+ polesneg+ romanianspos+ romaniansneg+ ruthenianspos+ rutheniansneg +  /*
*/slovakspos+ slovaksneg+ slovenespos+ slovenesneg+ slavspos+ slavsneg+ /*
*/nongermanspos+ nongermansneg+ nonhungarianspos+ nonhungariansneg+ /*
*/Christianspos+ Christiansneg+ RomanCatholicspos+ RomanCatholicsneg+ Protestantspos+ Protestantsneg+ /*
*/peopleofaprovincepos+ peopleofaprovinceneg+ peopleofaregionpos+ peopleofaregionneg+ peopleofacitypos+ peopleofacityneg+ localcommunitiespos+ localcommunitiesneg+ /*
*/Conservativespos+ Conservativesneg+ Clericalspos+ Clericalsneg+ Liberalspos+ Liberalsneg+  /*
*/Nationalistspos+ Nationalistsneg+ Socialistspos+Socialistsneg+ /*
*/menpos+ menneg+ womenpos+ womenneg+ /*
*/oldpos+ oldneg+ youngpos+ youngneg +/*
*/Othergroup

bysort doc_type: sum totalseg totalpol totalgr


*************************
*Calculate salience of each policy issue as percent of all policy issue categories coded in a given document 
*(positive plus negative claims, divided by total all issues claims)

gen greatergermany = (GreaterGermanypos + GreaterGermanyneg)/totalpol*100
gen war=(warmilitarismpos+warmilitarismneg)/totalpol*100 
gen milserv=(militaryservicepos + militaryserviceneg)/totalpol*100 
gen citarmy=(citizenarmypos+citizenarmyneg)/totalpol*100 

gen dem=(democracypos+democracyneg)/totalpol*100  
gen elecin=(electoralinclusionpos+electoralinclusionneg)/totalpol*100
gen parl=(parliamentaryautonomypos+parliamentaryautonomyneg)/totalpol*100  
gen civlib=(civillibertiespos+civillibertiesneg)/totalpol*100  
gen rulelaw=(ruleoflawpos+ruleoflawneg)/totalpol*100 
gen spechun=(specialstatusHungarypos+specialstatusHungaryneg)/totalpol*100 
gen fed=(federalismdecentralizationpos+federalismdecentralizationneg)/totalpol*100 
gen sec=(secessionpos+secessionneg)/totalpol*100 

gen capism=(capitalismpos+capitalismneg)/totalpol*100  
gen ftrade=(freetradepos+freetradeneg)/totalpol*100  
gen exploit=(exploitationpos+exploitationneg)/totalpol*100 
gen growth=(growthindustrialisationpos+growthindustrialisationneg)/totalpol*100 
gen unemp=(unemploymentpos+unemploymentneg)/totalpol*100  
gen debt=(publicdebtpos+publicdebtneg)/totalpol*100  
gen interest=(lowerinterestratespos+lowerinterestratesneg)/totalpol*100 
gen tax=(taxespos+taxesneg)/totalpol*100 

gen corp = (corporatismpos + corporatismneg)/totalpol*100
gen coop=(cooperativespos+cooperativesneg)/totalpol*100 
gen trunion=(tradeunionspos+tradeunionsneg)/totalpol*100  
gen infra=(publicinfrastructurepos+publicinfrastructureneg)/totalpol*100  
gen pubsub = (publicsubsidiespos + publicsubsidiesneg)/totalpol*100
gen agri = (agriculturepos + agricultureneg)/totalpol*100

gen soceq=(socialequalitypos+socialequalityneg)/totalpol*100 
gen socsec= (socialsecuritypos+socialsecurityneg)/totalpol*100  
gen pubhealth= (publichealthpos+publichealthneg)/totalpol*100 
gen pubeduc= (publiceducationpos+publiceducationneg)/totalpol*100 
gen classcon= (classconflictpos+classconflictneg)/totalpol*100  

gen tradval=(traditionalreligvaluespos+traditionalreligvaluesneg)/totalpol*100  
gen sepch=(separationchurchstatepos+separationchurchstateneg)/totalpol*100 

gen nationalism=(nationalismpos+nationalismneg)/totalpol*100  
gen langright=(speciallanguagerightspos+speciallanguagerightsneg)/totalpol*100  
gen grouprep=(grouprepresentationpos+grouprepresentationneg)/totalpol*100  
gen immig=(immigrationpos+immigrationneg)/totalpol*100 

gen otherissue=Otherissue/totalpol*100 


*Salience of issue fields
gen forpol = greatergermany + war+ milserv + citarmy
gen polsys = elecin + parl + dem+ civlib+ rulelaw+ spechun+ fed+ sec
gen econ = capism + ftrade+ exploit + unemp + debt + interest + tax + corp + coop + trunion + infra + pubsub + agri
gen socpol = soceq+ socsec+ pubhealth + pubeduc+ classcon
gen religmor = tradval + sepch
gen national = nationalism + langright+ grouprep+ immig


*Calculate salience of group appeals

gen civic=(civicidentitypos+civicidentityneg)/totalgr*100 

gen uppclass= (upperclasspos+upperclassneg)/totalgr*100 
gen midclass=(middleclasspos+middleclassneg)/totalgr*100 
gen lowclass=(lowerclasspos+lowerclassneg)/totalgr*100 
gen capists=(capitalistspos+capitalistsneg)/totalgr*100 
gen workers=(workerspos+workersneg)/totalgr*100 
gen aris=(aristocratspos+aristocratsneg)/totalgr*100 
gen farmers= (farmerspos+farmersneg)/totalgr*100 
gen merch=(merchantspos+merchantsneg)/totalgr*100 
gen craft=(craftspeoplepos+craftspeopleneg)/totalgr*100
gen civserv= (civilservantspos+ civilservantsneg)/totalgr*100
gen soldiers= (soldierspos+soldiersneg)/totalgr*100 
gen intellec= (intellectualspos+intellectualsneg)/totalgr*100 
gen produc= (producerspos+producersneg)/totalgr*100 
gen consum= (consumerspos+consumersneg)/totalgr*100 

gen bos = (bosniakspos + bosniaksneg)/totalgr*100
gen cro= (croatspos+croatsneg)/totalgr*100 
gen cze=(czechspos+czechsneg)/totalgr*100 
gen ger=(germanspos+germansneg)/totalgr*100
gen hun=(hungarianspos+hungariansneg)/totalgr*100
gen ita=(italianspos+italiansneg)/totalgr*100
gen jew=(jewspos+jewsneg)/totalgr*100 
gen nomadic = (nomadicpeoplepos+nomadicpeopleneg)/totalgr*100
gen pol=(polespos+polesneg)/totalgr*100
gen rom=(romanianspos+romaniansneg)/totalgr*100 
gen rut=(ruthenianspos+rutheniansneg)/totalgr*100 
gen sk=(slovakspos+slovaksneg)/totalgr*100
gen slo=(slovenespos+slovenesneg)/totalgr*100
gen slav=(slavspos+slavsneg)/totalgr*100 
gen nonger=(nongermanspos+nongermansneg)/totalgr*100
gen nonhun=(nonhungarianspos+nonhungariansneg)/totalgr*100 

gen christ=(Christianspos+Christiansneg)/totalgr*100 
gen romcat=(RomanCatholicspos+RomanCatholicsneg)/totalgr*100
gen prot=(Protestantspos+Protestantsneg)/totalgr*100

gen province=(peopleofaprovincepos+peopleofaprovinceneg)/totalgr*100 
gen region=(peopleofaregionpos+peopleofaregionneg)/totalgr*100 
gen city=(peopleofacitypos+peopleofacityneg)/totalgr*100 
gen local=(localcommunitiespos+localcommunitiesneg)/totalgr*100

gen conservatives=(Conservativespos+Conservativesneg)/totalgr*100 
gen clericals=(Clericalspos+Clericalsneg)/totalgr*100
gen liberals= (Liberalspos+Liberalsneg)/totalgr*100
gen nationalists= (Nationalistspos+Nationalistsneg)/totalgr*100 
gen socialists=(Socialistspos+Socialistsneg)/totalgr*100

gen men=(menpos+menneg)/totalgr*100
gen women=(womenpos+womenneg)/totalgr*100 

gen old=(oldpos+oldneg)/totalgr*100 
gen young=(youngpos+youngneg)/totalgr*100

gen othergr=Othergroup/totalgr*100


*Salience of group appeals by type

gen class= uppclass+ midclass+ lowclass+ capists+ workers+ aris+ farmers + merch+ craft+ civserv+ soldiers+ intellec+ produc+ consum
gen nationality=bos+cro +  cze+  ger+ hun+ita+ jew+ nomadic+ pol+ rom+ rut+ sk+slo+ slav+ nonger+ nonhun
gen religious=christ+romcat+prot
gen territorial=province+ region+  city+ local
gen ideological=conservatives+ clericals+  liberals+ nationalists+  socialists
gen gender=men+ women
gen age=old+ young



***** POSITIONS ******* 

*Calculation of positive and negative positions (log of raw count) for issue positions, following Lowe 2011
gen greatergermany_pos = log(GreaterGermanypos+0.5)
gen greatergermany_neg = log(GreaterGermanyneg+0.5)
gen war_pos=log(warmilitarismpos+0.5)
gen war_neg=log(warmilitarismneg+0.5)
gen milserv_pos=log(militaryservicepos+0.5)
gen milserv_neg=log(militaryserviceneg+0.5)
gen citarmy_pos=log(citizenarmypos+0.5)
gen citarmy_neg=log(citizenarmyneg+0.5)

gen dem_pos=log(democracypos+0.5)
gen dem_neg=log(democracyneg+0.5)
gen elecin_pos=log(electoralinclusionpos+0.5)
gen elecin_neg=log(electoralinclusionneg+0.5)
gen parl_pos=log(parliamentaryautonomypos+0.5)  
gen parl_neg=log(parliamentaryautonomyneg+0.5)
gen civlib_pos=log(civillibertiespos+0.5) 
gen civlib_neg=log(civillibertiesneg+0.5)  
gen rulelaw_pos=log(ruleoflawpos+0.5) 
gen rulelaw_neg=log(ruleoflawneg+0.5)  
gen spechun_pos=log(specialstatusHungarypos+0.5)
gen spechun_neg=log(specialstatusHungaryneg+0.5) 
gen fed_pos=log(federalismdecentralizationpos+0.5) 
gen fed_neg=log(federalismdecentralizationneg+0.5) 
gen sec_pos=log(secessionpos+0.5) 
gen sec_neg=log(secessionneg+0.5)

gen capism_pos=log(capitalismpos+0.5)  
gen capism_neg=log(capitalismneg+0.5)  
gen ftrade_pos=log(freetradepos+0.5)
gen ftrade_neg=log(freetradeneg+0.5) 
gen exploit_pos=log(exploitationpos+0.5) 
gen exploit_neg=log(exploitationneg+0.5)  
gen growth_pos=log(growthindustrialisationpos+0.5)
gen growth_neg= log(growthindustrialisationneg+0.5)  
gen unemp_pos=log(unemploymentpos+0.5)  
gen unemp_neg=log(unemploymentneg+0.5)  
gen debt_pos=log(publicdebtpos+0.5)  
gen debt_neg=log(publicdebtneg+0.5)  
gen interest_pos=log(lowerinterestratespos+0.5)
gen interest_neg=log(lowerinterestratesneg+0.5) 
gen tax_pos=log(taxespos+0.5) 
gen tax_neg=log(taxesneg+0.5) 
gen corp_pos =log(corporatismpos+0.5)
gen corp_neg =log(corporatismneg+0.5)
gen coop_pos=log(cooperativespos+0.5) 
gen coop_neg=log(cooperativesneg+0.5)
gen trunion_pos=log(tradeunionspos+0.5)  
gen trunion_neg= log(tradeunionsneg+0.5)  
gen infra_pos=log(publicinfrastructurepos+0.5)  
gen infra_neg=log(publicinfrastructureneg+0.5) 
gen pubsub_pos = log(publicsubsidiespos+0.5)
gen pubsub_neg = log(publicsubsidiesneg+0.5)
gen agri_pos = log(agriculturepos+0.5)
gen agri_neg = log(agricultureneg+0.5)

gen soceq_pos=log(socialequalitypos+0.5)
gen soceq_neg=log(socialequalityneg+0.5)  
gen socsec_pos= log(socialsecuritypos+0.5)
gen socsec_neg= log(socialsecurityneg+0.5)  
gen pubhealth_pos= log(publichealthpos+0.5)
gen pubhealth_neg= log(publichealthneg+0.5)
gen pubeduc_pos= log(publiceducationpos+0.5)
gen pubeduc_neg= log(publiceducationneg+0.5)  
gen classcon_pos= log(classconflictpos+0.5)
gen classcon_neg= log(classconflictneg+0.5)

gen tradval_pos=log(traditionalreligvaluespos+0.5) 
gen tradval_neg=log(traditionalreligvaluesneg+0.5)
gen sepch_pos=log(separationchurchstatepos+0.5) 
gen sepch_neg=log(separationchurchstateneg+0.5)

gen nationalism_pos=log(nationalismpos+0.5) 
gen nationalism_neg=log(nationalismneg+0.5)
gen langright_pos=log(speciallanguagerightspos+0.5)  
gen langright_neg= log(speciallanguagerightsneg+0.5)
gen grouprep_pos=log(grouprepresentationpos+0.5)
gen grouprep_neg=log(grouprepresentationneg+0.5) 
gen immig_pos=log(immigrationpos+0.5)
gen immig_neg=log(immigrationneg+0.5)


*Netto Positions on issues (positive minus negative)
gen p_greatergermany = greatergermany_pos - greatergermany_neg
gen p_war = war_pos - war_neg
gen p_milserv = milserv_pos - milserv_neg 
gen p_citarmy = citarmy_pos - citarmy_neg

gen p_dem = dem_pos - dem_neg
gen p_elecin = elecin_pos - elecin_neg
gen p_parl = parl_pos-parl_neg
gen p_civlib = civlib_pos - civlib_neg
gen p_rulelaw = rulelaw_pos - rulelaw_neg 
gen p_spechun = spechun_pos - spechun_neg
gen p_fed = fed_pos - fed_neg
gen p_sec = sec_pos - sec_neg

gen p_capism = capism_pos-capism_neg
gen p_ftrade = ftrade_pos-ftrade_neg
gen p_exploit = exploit_pos-exploit_neg
gen p_growth=growth_pos-growth_neg 
gen p_unemp = unemp_pos - unemp_neg
gen p_debt = debt_pos-debt_neg
gen p_interest = interest_pos - interest_neg
gen p_tax = tax_pos-tax_neg
gen p_corp = corp_pos - corp_neg
gen p_coop =coop_pos-coop_neg
gen p_trunion = trunion_pos-trunion_neg
gen p_infra = infra_pos-infra_neg
gen p_pubsub = pubsub_pos-pubsub_neg
gen p_agri = agri_pos-agri_neg

gen p_soceq= soceq_pos- soceq_neg 
gen p_socsec=socsec_pos-socsec_neg
gen p_pubhealth=pubhealth_pos- pubhealth_neg 
gen p_pubeduc=pubeduc_pos- pubeduc_neg
gen p_classcon = classcon_pos - classcon_neg 

gen p_tradval = tradval_pos - tradval_neg 
gen p_sepch = sepch_pos - sepch_neg

gen p_nationalism= nationalism_pos- nationalism_neg 
gen p_langright = langright_pos - langright_neg 
gen p_grouprep = grouprep_pos- grouprep_neg
gen p_immig = immig_pos - immig_neg 



*Calculation of pos neg (log of raw count) on groups

gen civic_pos=log(civicidentitypos+0.5)
gen civic_neg=log(civicidentityneg+0.5)

gen uppclass_pos= log(upperclasspos+0.5)
gen uppclass_neg=log(upperclassneg+0.5)
gen midclass_pos=log(middleclasspos+0.5)
gen midclass_neg=log(middleclassneg+0.5)
gen lowclass_pos=log(lowerclasspos+0.5)
gen lowclass_neg=log(lowerclassneg+0.5)
gen capitalists_pos=log(capitalistspos+0.5)
gen capitalists_neg=log(capitalistsneg+0.5)
gen workers_pos=log(workerspos+0.5)
gen workers_neg=log(workersneg+0.5)
gen aris_pos=log(aristocratspos+0.5)
gen aris_neg=log(aristocratsneg+0.5)
gen farmers_pos=log(farmerspos+0.5)
gen farmers_neg=log(farmersneg+0.5)
gen merch_pos=log(merchantspos+0.5)
gen merch_neg=log(merchantsneg+0.5)
gen craft_pos=log(craftspeoplepos+0.5)
gen craft_neg=log(craftspeopleneg+0.5)
gen civserv_neg=log(civilservantsneg+0.5)
gen civserv_pos=log(civilservantspos+0.5)
gen soldiers_pos=log(soldierspos+0.5)
gen soldiers_neg=log(soldiersneg+0.5)
gen intel_pos=log(intellectualspos+0.5)
gen intel_neg=log(intellectualsneg+0.5)
gen produc_pos=log(producerspos+0.5)
gen produc_neg=log(producersneg+0.5)
gen consum_pos=log(consumerspos+0.5)
gen consum_neg=log(consumersneg+0.5)

gen bos_pos=log(bosniakspos+0.5)
gen bos_neg=log(bosniaksneg+0.5)
gen cro_neg=log(croatsneg+0.5)
gen cro_pos=log(croatspos+0.5)
gen cze_pos=log(czechspos+0.5)
gen cze_neg=log(czechsneg+0.5)
gen ger_pos=log(germanspos+0.5)
gen ger_neg=log(germansneg+0.5)
gen hun_pos=log(hungarianspos+0.5)
gen hun_neg= log(hungariansneg+0.5)
gen ita_pos= log(italianspos+0.5)
gen ita_neg= log(italiansneg+0.5)
gen jew_pos= log(jewspos+0.5)
gen jew_neg= log(jewsneg+0.5)
gen nomadic_pos=log(nomadicpeoplepos+0.5)
gen nomadic_neg=log(nomadicpeopleneg+0.5)
gen pol_pos= log(polespos+0.5)
gen pol_neg= log(polesneg+0.5)
gen rom_pos= log(romanianspos+0.5)
gen rom_neg= log(romaniansneg+0.5)
gen rut_pos=log(ruthenianspos+0.5)
gen rut_neg= log(rutheniansneg+0.5)
gen sk_pos= log(slovakspos+0.5)
gen sk_neg= log(slovaksneg+0.5)
gen slo_pos= log(slovenespos+0.5)
gen slo_neg= log(slovenesneg+0.5)
gen slav_pos= log(slavspos+0.5)
gen slav_neg= log(slavsneg+0.5)
gen nonger_pos= log(nongermanspos+0.5)
gen nonger_neg= log(nongermansneg+0.5)
gen nonhun_pos= log(nonhungarianspos+0.5)
gen nonhun_neg= log(nonhungariansneg+0.5)

gen christ_pos=log(Christianspos+0.5)
gen christ_neg=log(Christiansneg+0.5)
gen romcat_pos=log(RomanCatholicspos+0.5)
gen romcat_neg= log(RomanCatholicsneg+0.5)
gen prot_pos= log(Protestantspos+0.5)
gen prot_neg=log(Protestantsneg+0.5)

gen province_pos=log(peopleofaprovincepos+0.5)
gen province_neg=log(peopleofaprovinceneg+0.5)
gen region_pos= log(peopleofaregionpos+0.5)
gen region_neg= log(peopleofaregionneg+0.5)
gen city_pos= log(peopleofacitypos+0.5)
gen city_neg= log(peopleofacityneg+0.5)
gen local_pos= log(localcommunitiespos+0.5)
gen local_neg= log(localcommunitiesneg+0.5)

gen conservatives_pos=log(Conservativespos+0.5)
gen conservatives_neg=log(Conservativesneg+0.5)
gen clericals_pos=log(Clericalspos+0.5)
gen clericals_neg= log(Clericalsneg+0.5)
gen liberals_pos= log(Liberalspos+0.5)
gen liberals_neg= log(Liberalsneg+0.5)
gen natists_pos= log(Nationalistspos+0.5)
gen natists_neg= log(Nationalistsneg+0.5)
gen socialists_pos= log(Socialistspos+0.5)
gen socialists_neg= log(Socialistsneg+0.5)

gen men_pos=log(menpos+0.5)
gen men_neg= log(menneg+0.5)
gen women_pos=log(womenpos+0.5)
gen women_neg=log(womenneg+0.5)

gen old_pos=log(oldpos+0.5)
gen old_neg=log(oldneg+0.5)
gen young_pos=log(youngpos+0.5)
gen young_neg=log(youngneg+0.5)




*Netto position on groups  

gen p_civic=civic_pos-civic_neg

gen p_uppclass = uppclass_pos- uppclass_neg
gen p_midclass = midclass_pos-midclass_neg
gen p_lowclass = lowclass_pos-lowclass_neg
gen p_capitalists = capitalists_pos-capitalists_neg
gen p_workers = workers_pos-workers_neg
gen p_aris = aris_pos - aris_neg
gen p_farmers = farmers_pos - farmers_neg
gen p_merch = merch_pos - merch_neg
gen p_craft = craft_pos - craft_neg
gen p_civserv = civserv_neg - civserv_pos
gen p_soldiers = soldiers_pos - soldiers_neg
gen p_intellec = intel_pos - intel_neg
gen p_produc = produc_pos - produc_neg
gen p_consum = consum_pos - consum_neg

gen p_bos = bos_pos - bos_neg
gen p_cro = cro_pos - cro_neg
gen p_cze = cze_pos - cze_neg
gen p_ger = ger_pos - ger_neg
gen p_hun = hun_pos - hun_neg
gen p_ita = ita_pos - ita_neg
gen p_jew = jew_pos - jew_neg
gen p_nomadic = nomadic_pos- nomadic_neg
gen p_pol = pol_pos - pol_neg
gen p_rom = rom_pos - rom_neg
gen p_rut = rut_pos - rut_neg
gen p_sk = sk_pos - sk_neg
gen p_slo = slo_pos - slo_neg
gen p_slav = slav_pos - slav_neg
gen p_nonger = nonger_pos - nonger_neg
gen p_nonhun = nonhun_pos - nonhun_neg

gen p_christ = christ_pos - christ_neg
gen p_romcat = romcat_pos - romcat_neg
gen p_prot = prot_pos - prot_neg

gen p_province = province_pos - province_neg
gen p_region = region_pos - region_neg
gen p_city = city_pos - city_neg
gen p_local = local_pos - local_neg

gen p_conservatives = conservatives_pos - conservatives_neg
gen p_clericals = clericals_pos - clericals_neg
gen p_liberals = liberals_pos - liberals_neg
gen p_nationalists = natists_pos - natists_neg
gen p_socialists = socialists_pos - socialists_neg 

gen p_men = men_pos - men_neg
gen p_women = women_pos - women_neg 

gen p_old = old_pos - old_neg 
gen p_young = young_pos - young_neg



*Generate doc_type as numerical variable (1=EA, 2=PP, 3=RS)
gen doc_type1=1
replace doc_type1=2 if doc_type=="PP"
replace doc_type1=3 if doc_type=="RS"


*Generate election variable
gen elec=2
replace elec=1 if doc_year<1898
replace elec=3 if doc_year>1901
replace elec=4 if doc_year>1907


*genrate variable to separate pre and post-electoral reform documents which is relevant for the party programs, 
*since we tried to collect one longer pre- and one longer post-reform document (party programme) per party.
*the relevant reform is the reform that introduced full male suffrage for all seats in the Abgeordnetenhaus

gen postsuffrage_pp = 0
replace postsuffrage_pp = 1 if doc_year > 1905

*adapt sorting for party programmes that were adopted / reformed earlier and then remained in force for 1907 election 

replace postsuffrage_pp = 1 if doc_title == "1903 Program Czech agrarian party-shortened"
replace postsuffrage_pp = 1 if doc_title == "1902 National socialist programme"
replace postsuffrage_pp = 1 if doc_title == "1902 and 1906 Small Business-Radical progressives programme" 

replace postsuffrage_pp = 1 if doc_title == "Sozdem 1899 Brünner Nationalitätenprogramm"
replace postsuffrage_pp = 1 if doc_title == "Sozdem 1901 Wiener Programm"
replace postsuffrage_pp = 1 if doc_title == "DVolksP 1900"
replace postsuffrage_pp = 1 if doc_title == "Chrsoz 1905 Parteitagsresolution"


*generate variable to classify manifestos as predominantly nationalist according to their "core issue"
*can be used to classify parties as nationalist
gen natdoc = 0
replace natdoc = 1 if core_issue_1 == "nationalism pos"

gen natdoc2 = 0
replace natdoc2 = 1 if core_issue_1 == "nationalism pos"
replace natdoc2 = 1 if core_issue_2 == "nationalism pos"

save "manifestos1", replace



